// 组件状态

import React from 'react'
import ReactDOM from 'react-dom'

class Hello extends React.Component {
  state = {
    text: '123',
    checked: false
  }

  getValue = () => {
    console.log('状态：', this.state)
  }

  render() {
    return (
      <div>
        <input
          type="text"
          value={this.state.text}
          onChange={e =>
            this.setState({
              text: e.target.value
            })
          }
        />

        <input
          type="checkbox"
          value={this.state.checked}
          onChange={e =>
            this.setState({
              checked: e.target.checked
            })
          }
        />
        <button onClick={this.getValue}>获取文本框的值</button>
      </div>
    )
  }
}

// 渲染
ReactDOM.render(<Hello />, document.getElementById('root'))
